import { View } from "@tarojs/components"
import { Switch } from "@antmjs/vantui"
import WowField from "../WowField"
import "./index.less"
import { useEffect, useState } from "react"

const WowHasKey = props => {

  const [hasKey, setHasKey] = useState(false)

  const switchChange = e => {
    setHasKey(e.detail)
  }

  useEffect(() => {
    props.onChange && props.onChange(hasKey)
  }, [hasKey])

  return (
    <View className="wow-has-key-wrapper">
      <WowField
        disabled
        renderIcon={
          <Switch
            activeColor="#FFDD19"
            inactiveColor="#B7B7B7"
            size="20px"
            checked={hasKey}
            onChange={switchChange} />
        }
        placeholder="有无钥匙" />
    </View>
  )
}

export default WowHasKey